//基类Shape
abstract class Shape {
    //纯虚方法，计算面积
    public abstract double calculateArea();
}
//子类Circle
class Circle extends Shape {
    private double r;
    // 定义 PI 为常量
    public static final double PI = 3.14;
    public Circle(double r) {
        this.r = r;
    }
    //计算圆的面积
    @Override
    public double calculateArea() {
        return PI * r * r; // 使用PI计算圆的面积
    }
}
//子类Rectangle
class Rectangle extends Shape {
    private double l, w;
    public Rectangle(double l, double w) {
        this.l = l;
        this.w = w;
    }
    //计算矩形的面积
    @Override
    public double calculateArea() {
        return l * w; //矩形的面积公式
    }
}
//主函数
class Main {
    public static void main(String[] args) {
        //创建 Circle和Rectangle对象
        Shape circle = new Circle(3);
        Shape rectangle = new Rectangle(5, 3);
        //分别计算并输出它们的面积
        System.out.println("S circle: " + circle.calculateArea());
        System.out.println("S rectangle: " + rectangle.calculateArea());
    }
}
